package org.jeecg.modules.iot.aio;

import org.tio.utils.lock.MapWithLock;

import java.util.HashMap;

/**
 * 这里是一个注释
 *
 * @author scw
 * @version v1.0
 * @date
 */
public class Aio {

    /**
     * 根据productKey，分别存储对应的配置
     */
    private static MapWithLock<String, AioConfiguration> confMap = new MapWithLock<>(new HashMap<String, AioConfiguration>());

    /**
     * 初始化保存对应产品的AioConfiguration
     * @param productKey
     * @param aioConfiguration
     */
    public static synchronized void setConfMap(String productKey,AioConfiguration aioConfiguration){
        Aio.confMap.put(productKey,aioConfiguration);
    }

    /**
     * 根据productKey获取其配置类
     * @param productKey
     * @return AioConfiguration
     */
    public static AioConfiguration getAioConfiguration(String productKey){
        if(productKey == null) throw new RuntimeException("Parameter productKey is null");
        return confMap.get(productKey);
    }

}
